/*
 * $AIST_Release: 0.9.0 $
 * Copyright 2011 Information Technology Research Institute, National
 * Institute of Advanced Industrial Science and Technology
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *    http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package generator

import util.OptionParser._

/**
 * Module for command line options.
 */
object Options extends Options

trait Options {
  trait CmdOpt 
  object DumpTree   extends CmdOpt
  object NoInput    extends CmdOpt
  object Text       extends CmdOpt
  object BytesList  extends CmdOpt
  object LeaveFiles extends CmdOpt
  object Help       extends CmdOpt

  def opts = List(
    OptDesc(DumpTree,   List(),    List("dump-tree"),   NoArg, "Dumps the analyzed tree."),
    OptDesc(NoInput,    List(),    List("no-input"),    NoArg, "Does not read data from standard input and run once with UndefValue."),
    OptDesc(Text,       List(),    List("text"),        NoArg, "Uses text as ouput data format."),
    OptDesc(BytesList,  List(),    List("bytes-list"),  NoArg, "Uses bytes list as input."),
    OptDesc(LeaveFiles, List(),    List("leave-files"), NoArg, "Leaves the generated files(Does not remove the files at exit)."),
    OptDesc(Help,       List('h'), List("help"),        NoArg, "Print this.")
  )

  def parse(args: Array[String]) = parseOpt(opts, args.toList)

  def usage(cmd: String, args: String*): Unit = {
    println("Usage:")
    println("\t%s [OPTIONS] %s".format(cmd, args.mkString(" ")))
    println("Options:")
    println(util.OptionParser.usage(opts))
  }
}
